<template>
	<view class="content">
		<view class="abc">
			<view class="new_item">
						<view class="dtcll">
							<text>类型</text>
						</view>
						<view class="dtcll">
							<text>名称</text>
						</view>
						<view class="dtcll">
							<text>起点</text>
						</view>
						<view class="dtcll">
							<text>起点库区</text>
						</view>
						<view class="dtcll">
							<text>终点</text>
						</view>
						<view class="dtcll">
							<text>终点库区</text>
						</view>
					</view>
					<view>{{activeArr[0].agv_name}}</view>
			<view   v-for="(item,index) in activeArr" :key="item.id" @click="goDetail(item.id)" :class="['new_item' ,item.task_type == 'r2r' ? 'task_typeA':'',item.task_type == 'park' ? 'task_typeB':'',item.task_type == 'r2c' ? 'task_typeA':'',item.task_type == 'travel' ? 'task_typeB':'',item.task_type == 'c2c' ? 'task_typeA':'',item.task_type == 'avoidance' ? 'task_typeB':'',item.task_type == 'c2r' ? 'task_typeA':'',item.task_type == 'carry' ? 'task_typeB':'',item.task_type == 'charge' ? 'task_typeB':'' ]">
				<view class="cll">
					
					<!-- <text>{{item.task_type}}</text> -->
					<text>{{item.task_type == 'r2r' ? '资源到资源' : ''}}{{item.task_type == 'r2c' ? '资源到仓库' : ''}}{{item.task_type == 'c2c' ? '仓库到仓库' : ''}}{{item.task_type == 'c2r' ? '仓库到资源' : ''}}{{item.task_type == 'charge' ? '充电' : ''}}{{item.task_type == 'park' ? '停靠' : ''}}{{item.task_type == 'travel' ? '临时' : ''}}{{item.task_type == 'avoidance' ? '避让' : ''}}{{item.task_type == 'carry' ? '搬运' : ''}}</text>
<!-- 					
					任务类型  r2r资源到资源 r2c资源到仓库
					 c2c仓库到仓库 c2r仓库到资源 charge充电 park停靠 travel临时 avoidance避让 carry搬运 -->
				</view>
				<view class="cll">
					<text>{{item.agv_name}}</text>
				</view>
				<view class="cll">
					<text>{{item.origin}}</text>
				</view>
				<view  class="cll">
					<text>{{item.origin_area}}</text>
				</view>
				<view  class="cll">
					<text>{{item.destination}}</text>
				</view>
				<view  class="cll">
					<text>{{item.destination_area}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activeArr: [],
				index: 1,
				flag: false,
			}
		},
		methods: {
			async sendPost(){
				
				const res = await this.$myRequest({
					url: '/makerwit/wms/queryTaskInfoAndIndex',
					data: '{\"finished\": 0,\"index\":\"'+this.index+'\"}',
					method: 'POST'
				})
				console.log('=============================',res.data.data)
				// this.activeArr =[...this.activeArr,...res.data.data] 
				this.activeArr =[...this.activeArr, ...res.data.data]
			},
			goDetail (id) {
				
				uni.navigateTo({
					url: '/pages/taskInfo/taskInfo?id='+id
				})
				
			}
			
		},
		onLoad() {
			this.sendPost()
			
		},
		onReachBottom() {
			// if(this.activeArr.length < 10*this.index)
			//用于判断触底时，当前页面的数据条数是否为最大条数，如果是，则禁止访问接口
			if(this.activeArr.length < 15*this.index) return this.flag = true
			console.log('触底了',this.activeArr.length)
			this.index++
			this.sendPost()
			
		},
		filters: {
			formatDate: function (value) {
				let date = new Date(value);
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM;
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h;
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m;
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s;
				return y + '-' + MM + '-' + d + '\n' + h + ':' + m + ':' + s;
			}
		}
	}
</script>

<style lang="scss">
.new_item{
	display: flex;
	border-bottom: 1px solid #EEEEEE;
	height: 45px;
	padding: 5px;
	.cll{
		width: 16.6666%;
		text{
			height: 45px;
			color: #FFFFFF;
			font-size: 25rpx;
			display: flex;
			  align-items: center;
			justify-content: center;
		}
	}
	
}
	.content{
		width: 100%;
	}
.abc{
	
	}
	
	.dtcll{
		width: 16.6666%;
		height: 45px;	
		
		text{
			height: 45px;
		
			font-size: 25rpx;
			display: flex;
			  align-items: center;
			justify-content: center;
		}
	}
	.task_typeA{
		background: #007AFF;
	}
	.task_typeB{
		background: #19BE6B;
	}
</style>
